#include "stdafx.h"
#include "_XMarker.h"
#include "_GraphLayout.h"

void _XMarker::draw(double Min, double Max, _u32 BorderSize, _u32 YAxisWidth, _u32 XAxisHeight, _u32 TitleHeight)
{
    glColor3i(GET_GLINT_R(m_Color), GET_GLINT_G(m_Color), GET_GLINT_B(m_Color));
    glLoadIdentity();
    _u32 Width  = m_Layout.m_ControlRect.Width() - m_Layout.m_BorderSize * 2 - m_Layout.m_YAxisWidth;
    _u32 Height = m_Layout.m_ControlRect.Height() - m_Layout.m_BorderSize * 2 - m_Layout.m_XAxisHeight - m_Layout.m_TitleHeight;
    glViewport(BorderSize + m_Layout.m_YAxisWidth,
               BorderSize + m_Layout.m_XAxisHeight,
               Width,
               Height);
    gluOrtho2D(Min, Max, 0, Height);
    glBegin(GL_TRIANGLE_STRIP);
    glVertex2d(m_Value, 5);
    glVertex2d(m_Value + (Max - Min) / (m_Layout.m_ControlRect.Width() - m_Layout.m_YAxisWidth - m_Layout.m_BorderSize * 2) * 5, 0);
    glVertex2d(m_Value - (Max - Min) / (m_Layout.m_ControlRect.Width() - m_Layout.m_YAxisWidth - m_Layout.m_BorderSize * 2) * 5, 0);
    glEnd();
    glBegin(GL_LINE_STRIP);
    glVertex2d(m_Value, 5);
    glVertex2d(m_Value, m_Layout.m_ControlRect.Height() - m_Layout.m_TitleHeight - BorderSize);
    glEnd();
    drawText(m_Caption, OGL_DRAWABLE_FONT_ARIAL_10, m_Value + (Max - Min) / (m_Layout.m_ControlRect.Width() - m_Layout.m_YAxisWidth - m_Layout.m_BorderSize * 2) * 5, 10, GET_GLINT_R(m_Color), GET_GLINT_G(m_Color), GET_GLINT_B(m_Color));
}